<template>
	<view>
		<view class="pake" v-for="(item,key) in pakelist" :key="key" @click="buy(item.id,item.comboName)">
			<view class="pake1">
				<text style="width: 80%;">
					<image :src="item.picture" class="paketu"></image>
					<text class="pake_zi1">{{item.value>1024?item.value/1024+'GB':item.value+'MB'}}/{{item.day}}{{$t('app.ri')}}</text>
				</text>
			</view>
			<view class="pake1">
				<view class="pake1_2">
					<view class="pake_zi2">{{$t('flow.goumai')}}</view> 
					<text  class="pake_zi2" @click.stop="telphone()">{{$t('flow.boda')}}{{item.orderMethod}}</text>
				</view>

				<text class="pake_zi3">{{item.price}}<text style="color: black; font-size: 14px;">{{$t('app.kips')}}</text></text>
			</view>
			<!-- <view class="pake1">
				<u-button type="primary" text="立即购买" color="red" style="width: 50%;margin-top: 10px;"></u-button>
			</view> -->
			<view class="box">
				<view class="box">
					<u-badge numberType="overflow" :type="type" max="99" value="hot"></u-badge>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
		import { getResponseData, showToastTip,getBaseUrl,getWsUrl} from "@/api/req.js";
	export default {
		data() {
			return {
				type: "warning",
				pakelist: []
			}
		},
		onLoad() {
			var that = this;
			// 得到用户数据
			getResponseData("/combo/getCombo", 'get',{}, function(res) {
				if (res.code == 200) {
					console.log(res);
					that.pakelist = res.data;
				}else{
					uni.showToast({
						title: res.msg,
						icon: 'none',
						duration: 2000
					})
				}
			});
		},
		methods: {
			buy: function(id,name) {
				uni.showModal({
					title: this.$t('buywifi.buy'),
					content: this.$t('flow.buy')+ name + '？',
					confirmText:this.$t('app.qd'),
					cancelText:this.$t('app.qx'),
					success: function(res) {
						if (res.confirm) {
						     getResponseData("/combo/buyCombo"
						     , 'get',{
						     	id:id
						     }, function(res) {
						     	// console.log(res.data);
								if(res.code){
									uni.showToast({
										title: res.msg,
										icon: 'none',
										duration: 2000
									})
								}
						     	
						     });
						} else {
							
						}
					}
				})
			
			},
			telphone() {
				uni.makePhoneCall({
					// phoneNumber: '114' //仅为示例
				});
			}

		}
	}
</script>

<style lang="scss" scoped>
	.pake {
		width: 90%;
		margin: auto;
		border: 1px #1eb9ee solid;
		border-radius: 5px;
		margin-top: 20px;
		position: relative;
	}

	.pake1 {
		display: flex;
		justify-content: space-around;
		padding: 15px 0px 5px;
	}
	
	.pake1_2{
		width: 40%;
	}

	.pake1>text {
		// width: 20%;
		// padding: 5px 0px;
		/* border: 1px black solid; */
	}

	.paketu {
		width: 100rpx;
		height: 100rpx;
		/* padding-top: 10px; */
		float: left;
		// border-radius: 50px;
	}

	.pake_zi1 {
		padding-left: 40px;
		float: left;
		line-height: 50px;
		font-size: 18px;
		font-weight: 600;
	}

	.pake_zi2 {
		font-size: 16px;
		color: gray;
		// line-height: 25px;	
	}

	.pake_zi3 {
		font-size: 16px;
		font-weight: 600;
		color: goldenrod;
		line-height: 40px;
	}

	.box {
		width: 30px;
		height: 20px;
		// background-color: #909193;
		border-radius: 15px;
		position: absolute;
		top: 0px;
		right: 0px;
	}
</style>